<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="inet.db.tennis.TennisChampion"%>
<%@page import="inet.db.tennis.buffer.TennisSeasonBuffer"%>
<%@page import="inet.db.tennis.TennisCountry"%>
<%@page import="java.math.BigDecimal"%>
<jsp:useBean id="tennisCountryDAO" class="inet.db.tennis.TennisCountryDAO" scope="session"/>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>Danh sách quốc gia</title>
    <link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/admin/tennis/css/reset.css" media="screen" />
    <link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/admin/tennis/css/text.css" media="screen" />
    <link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/admin/tennis/css/grid.css" media="screen" />
    <link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/admin/tennis/css/layout.css" media="screen" />
    <link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/admin/tennis/css/nav.css" media="screen" />
    <!--[if IE 6]><link rel="stylesheet" type="text/css" href="css/ie6.css" media="screen" /><![endif]-->
    <!--[if IE 7]><link rel="stylesheet" type="text/css" href="css/ie.css" media="screen" /><![endif]-->
    <link href="<%= request.getContextPath() %>/admin/tennis/css/table/demo_page.css" rel="stylesheet" type="text/css" />
    <!-- BEGIN: load jquery -->
    <script src="<%= request.getContextPath() %>/admin/tennis/js/jquery-1.6.4.min.js" type="text/javascript"></script>
    <script type="<%= request.getContextPath() %>/admin/tennis/text/javascript" src="js/jquery-ui/jquery.ui.core.min.js"></script>
    <script src="<%= request.getContextPath() %>/admin/tennis/js/jquery-ui/jquery.ui.widget.min.js" type="text/javascript"></script>
    <script src="<%= request.getContextPath() %>/admin/tennis/js/jquery-ui/jquery.ui.accordion.min.js" type="text/javascript"></script>
    <script src="<%= request.getContextPath() %>/admin/tennis/js/jquery-ui/jquery.effects.core.min.js" type="text/javascript"></script>
    <script src="<%= request.getContextPath() %>/admin/tennis/js/jquery-ui/jquery.effects.slide.min.js" type="text/javascript"></script>
    <script src="<%= request.getContextPath() %>/admin/tennis/js/jquery-ui/jquery.ui.mouse.min.js" type="text/javascript"></script>
    <script src="<%= request.getContextPath() %>/admin/tennis/js/jquery-ui/jquery.ui.sortable.min.js" type="text/javascript"></script>
    <script src="<%= request.getContextPath() %>/admin/tennis/js/table/jquery.dataTables.min.js" type="text/javascript"></script>
    <!-- END: load jquery -->
    <script type="text/javascript" src="<%= request.getContextPath() %>/admin/tennis/js/table/table.js"></script>
    <script src="<%= request.getContextPath() %>/admin/tennis/js/setup.js" type="text/javascript"></script>
    <script type="text/javascript">

        $(document).ready(function () {
            setupLeftMenu();

            $('.datatable').dataTable();
			setSidebarHeight();


        });
    </script>
    <script type="text/javascript">
    	function f_delete_select_item() {
    		document.formListCountries.action.value = 'delete_selected';
    		document.formListCountries.submit();
    	}
    </script>
</head>
<body>
    <div class="container_12">
        <%@ include file="../include/header.jsp" %>
        <% 
        	// Delete selected rows
    		String sAction = request.getParameter("action");
    		if(sAction != null && "delete_selected".equals(sAction)) {
    			String[] selected = request.getParameterValues("chkID");
    			if (selected != null && selected.length > 0) {
		            for (int i = 0; i < selected.length; i++) {
						tennisCountryDAO.deleteRow(new BigDecimal(selected[i]));
		            }
		        }
    		}
    		
        	Vector<TennisCountry> vTennisCountry = tennisCountryDAO.findAll();
        %>
        <div class="grid_5">
            <div class="box round first grid">
                <h2>Danh sách quốc gia</h2>
                <div class="block">
                	<form name="formListCountries" method="post">
                		<input type="hidden" name="action"/>
	                    <table class="data display datatable" id="example">
							<thead>
								<tr>
									<th style="width: 5%;">&nbsp;</th>
									<th style="width: 35%;">Tên nước</th>
									<th style="width: 15%;">Logo</th>
									<th style="width: 5%;">Sửa</th>
								</tr>
							</thead>
							<tbody>
								<% 
									if(vTennisCountry != null && !vTennisCountry.isEmpty()) {
										TennisCountry country = null;
										int i = 0;
										String seasonName = "";
										for (Iterator it = vTennisCountry.iterator(); it.hasNext(); ) {
											country = (TennisCountry)it.next();
											if( country == null ) continue;
								%>
								<tr class="gradeA">
									<td>
										<input type="checkbox" name="chkID" value="<%= country.getId() %>" />
									</td>
									<td><%= country.getCountryName() %></td>
									<td>Logo</td>
									<td>
										<a href="edit-country.jsp?id=<%= country.getId() %>">
											<img style="vertical-align: middle;" src="<%= request.getContextPath() %>/admin/tennis/img/cog.png" />
										</a>
									</td>
								</tr>
								<% 
										}
									}
								%>
							</tbody>
						</table>
					</form>
	                <a href="add-country.jsp" class="btn-mini btn-black btn-plus" title="Thêm mới"><span></span>Add</a>
	                <a onclick="if(confirm('Bạn có chắc chắn muốn xóa ??? ')){f_delete_select_item();}" class="btn-mini btn-black btn-cross" title="Xóa"><span></span>Delete</a>
                </div>
            </div>
        </div>
        <div class="clear">
        </div>
    </div>
    <%@ include file="../include/footer.jsp" %>
</body>
</html>